package leetcode;

public class LC23 {
    public static void main(String[] args) {

        LC23 lc23 = new LC23();
        ListNode ha = new ListNode(4);
        ListNode hb = new ListNode(5);
        hb.next = new ListNode(6);
        ha.next = hb.next.next = new ListNode(1);
        ha.next.next = hb.next.next.next = new ListNode(8);
        ha.next.next.next= hb.next.next .next.next = new ListNode(4);
        ha.next.next.next.next= hb.next.next .next.next.next = new ListNode(5);
        lc23.reverseList(ha);
    }
    public ListNode reverseList(ListNode head) {
        ListNode next = head;
        ListNode ans = null;
        while(next != null){
            ListNode temp = next.next;
            next.next = ans;
            ans = next;
            next = temp;
        }
        return ans;
    }
}
